package com.qidian.buy.controller;

import com.qidian.buy.entity.Content;
import com.qidian.buy.service.IContentService;
import com.qidian.buy.util.pojo.LayuiTableDTO;
import com.qidian.buy.util.pojo.QDResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author 郭浩
 */
@RestController
@RequestMapping("/content")
@CrossOrigin
public class ContentController {
    @Autowired
    private IContentService contentService;
    @RequestMapping("/save")
    public QDResult save(Content content){
        return contentService.save(content);
    }

    @RequestMapping("/edit")
    public QDResult edit(Content content){
        return contentService.edit(content);
    }

    @RequestMapping("/delete")
    public QDResult delete(Content content){
        return contentService.delete(content);
    }

    @RequestMapping("/get")
    public QDResult get(Long id){
        return contentService.get(id);
    }

    @RequestMapping("/query")
    public LayuiTableDTO<Content> query(Content content, @RequestParam(defaultValue = "1") int page, @RequestParam(defaultValue = "10")int limit){
        return contentService.query(page,limit,content);
    }
}
